#include<iostream>
#include<algorithm>
using namespace std;
int a[10] = { 1,2,3,4,5,6,7,8,9 };
int result(int l, int r)
{
	int sum = 0;
	for (int i = l; i <= r; i++)
	{
		sum = sum * 10 + a[i];
	}
	return sum;
}
int main()
{
	int n;
	int res = 0;
	cin >> n;
	do {
		int x = 0, y = 0, z = 0;
		for (int i = 0; i < 7; i++)
		{
			x = result(0, i);
			if (x >= n) {
				break;
			}
			for (int j = i + 1; j < 8; j++)
			{
				y = result(i + 1, j);
				z = result(j + 1, 8);
				if (y % z == 0 && (x + y / z) == n) {
					res++;
				}
			}
		}
	} while (next_permutation(a, a + 9));
	cout << res;
	return 0;
}